package com.example.atools;

import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.StrictMode;
import android.util.Log;
/**
 * Nguyen Van Son
 * @author nguyenson
 *
 */


@SuppressLint("NewApi")
public class BootReceiver extends BroadcastReceiver {
	    @SuppressLint("NewApi")
		@Override
	    public void onReceive(final Context context, final Intent intent) {
	            if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {    
	        		try {
	        			if (android.os.Build.VERSION.SDK_INT > 9) {
	        				StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
	        				StrictMode.setThreadPolicy(policy);
	        			}
	        		}
	        		catch (Exception e){}	            	
	        		
	            	MyScheRcv.loadConfig(context);
	            	Tools.setAlarm(context);
	            	
//	                    Intent mServiceIntent = new Intent();
//	                    mServiceIntent.setAction("com.example.test1.BootService");
//	                    ComponentName service = context.startService(mServiceIntent);
//	                    if (null == service) {
//	                            // something really wrong here
//	                            Log.e("BootReceiver", "Could not start service ");
//	                    }
	            } else {
	                    Log.e("BootReceiver", "Received unexpected intent " + intent.toString());
	            }
	    }
}
